package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.job.dto.*;
import com.insigma.business.qrcode.job.dto.request.JobRecruitPositionTypeInsertRequest;
import com.insigma.business.qrcode.job.dto.request.JobRecruitPositionTypeSearchRequest;
import com.insigma.business.qrcode.job.dto.request.JobRecruitPositionTypeUpdateRequest;
import com.insigma.business.qrcode.job.dto.search.JobRecruitPositionTypeBSearcher;
import com.insigma.business.qrcode.job.entity.JobRecruitPositionTypeDO;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class JobRecruitPositionTypeProviderConverter extends AbstractConverter<JobRecruitPositionTypeDTO, JobRecruitPositionTypeDO> {

    private final static JobRecruitPositionTypeProviderConverter jobRecruitPositionTypeConverter = new JobRecruitPositionTypeProviderConverter();

    private JobRecruitPositionTypeProviderConverter(){}

    
    public static JobRecruitPositionTypeBSearcher convertRequestSO2Searcher(final JobRecruitPositionTypeSearchRequest request){
        final JobRecruitPositionTypeBSearcher jobRecruitPositionTypeBSearcher = new JobRecruitPositionTypeBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,jobRecruitPositionTypeBSearcher);
        return jobRecruitPositionTypeBSearcher;
    }

    
    public static JobRecruitPositionTypeDO convertRequestUO2DO(final JobRecruitPositionTypeUpdateRequest jobRecruitPositionTypeUpdateRequest) {
        final JobRecruitPositionTypeDO jobRecruitPositionTypeDO = new JobRecruitPositionTypeDO();
        BeanUtils.copyProperties(jobRecruitPositionTypeUpdateRequest,jobRecruitPositionTypeDO);
        
        return jobRecruitPositionTypeDO;
    }

    
    public static JobRecruitPositionTypeDO convertRequestIO2DO(final JobRecruitPositionTypeInsertRequest jobRecruitPositionTypeInsertRequest) {
        final JobRecruitPositionTypeDO jobRecruitPositionTypeDO = new JobRecruitPositionTypeDO();
        BeanUtils.copyProperties(jobRecruitPositionTypeInsertRequest,jobRecruitPositionTypeDO);
        return jobRecruitPositionTypeDO;
    }

    
    public static List<JobRecruitPositionTypeDTO> convertResponseDOList2DTOList(final List<JobRecruitPositionTypeDO> jobRecruitPositionTypeDOList){
        return jobRecruitPositionTypeConverter.convertGenericResponseDOList2DTOList(jobRecruitPositionTypeDOList);
    }

    
    public static JobRecruitPositionTypeDTO convertResponseDO2DTO(final JobRecruitPositionTypeDO jobRecruitPositionTypeDO){
        return jobRecruitPositionTypeConverter.convertGenericResponseDO2DTO(jobRecruitPositionTypeDO);
    }

    public static JobRecruitPositionTypeDTO convertToNewDto(JobRecruitPositionTypeDO jobRecruitPositionTypeDO) {
        JobRecruitPositionTypeDTO dto = new JobRecruitPositionTypeDTO();
        BeanUtils.copyProperties(jobRecruitPositionTypeDO,dto);
        dto.setLabel(jobRecruitPositionTypeDO.getName());
        dto.setValue(jobRecruitPositionTypeDO.getCode());
        return dto;
    }

    @Override
    protected JobRecruitPositionTypeDTO doConvertResponseDO2DTO(JobRecruitPositionTypeDO jobRecruitPositionTypeDO) {
        final JobRecruitPositionTypeDTO jobRecruitPositionTypeDTO = new JobRecruitPositionTypeDTO();
        try {
            BeanUtils.copyProperties(jobRecruitPositionTypeDO, jobRecruitPositionTypeDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return jobRecruitPositionTypeDTO;
    }

}
